What is is-absolute?
The is-absolute npm package is a utility that helps determine if a given file path is an absolute path. This can be particularly useful in file system operations where the distinction between absolute and relative paths is important.
What are is-absolute's main functionalities?
Check if a path is absolute
This feature allows you to check if a given path is absolute. An absolute path is one that starts from the root directory, as opposed to a relative path which is relative to the current working directory.
const isAbsolute = require('is-absolute');
console.log(isAbsolute('/home/user')); // true
console.log(isAbsolute('home/user')); // false
Other packages similar to is-absolute
path-is-absolute
The path-is-absolute package provides similar functionality to is-absolute by determining if a given path is absolute. It is a lightweight package and can be used as a drop-in replacement for is-absolute.
path
The path module is a core Node.js module that provides utilities for working with file and directory paths. It includes a method called path.isAbsolute() which can be used to check if a path is absolute. This module offers a broader range of path-related utilities compared to is-absolute.
is-absolute
Polyfill for node.js path.isAbolute
. Returns true if a file path is absolute.
Install
Install with npm:
$ npm install --save is-absolute
Originally based on the isAbsolute
utility method in express.
Usage
var isAbsolute = require('is-absolute');
isAbsolute('a/b/c.js');
isAbsolute('/a/b/c.js');
Explicitly test windows paths
isAbsolute.posix('/foo/bar');
isAbsolute.posix('/user/docs/Letter.txt');
isAbsolute.posix('foo/bar');
Explicitly test windows paths
var isAbsolute = require('is-absolute');
isAbsolute.win32('c:\\');
isAbsolute.win32('//C://user\\docs\\Letter.txt');
isAbsolute.win32('\\\\unc\\share');
isAbsolute.win32('\\\\unc\\share\\foo');
isAbsolute.win32('\\\\unc\\share\\foo\\');
isAbsolute.win32('\\\\unc\\share\\foo\\bar');
isAbsolute.win32('\\\\unc\\share\\foo\\bar\\');
isAbsolute.win32('\\\\unc\\share\\foo\\bar\\baz');
isAbsolute.win32('a:foo/a/b/c/d');
isAbsolute.win32(':\\');
isAbsolute.win32('foo\\bar\\baz');
isAbsolute.win32('foo\\bar\\baz\\');
About
Related projects
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Contributors
Building docs
(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)
To generate the readme and API documentation with verb:
$ npm install -g verb verb-generate-readme && verb
Running tests
Install dev dependencies:
$ npm install -d && npm test
Author
Jon Schlinkert
License
Copyright © 2016, Jon Schlinkert.
Released under the MIT license.
This file was generated by verb-generate-readme, v0.1.31, on October 16, 2016.